'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    const { STRING, INTEGER, DATE } = Sequelize;
    await queryInterface.createTable('video_follows', {
      id: {
        type: INTEGER(20).UNSIGNED,
        autoIncrement: true,
        primaryKey: true,
      },
      user_id: {
        type: INTEGER(20).UNSIGNED,
        allowNull: false,
        comment: '用户id 发起关注者',
        references: {
          model: 'user',
          key: 'id'
        },
        onUpdate: "restrict", // 更新时操作
        onDelete: "cascade", // 删除时操作
      },
      to_user_id: {
        type: INTEGER(20).UNSIGNED,
        allowNull: false,
        comment: '用户id 被关注者',
        references: {
          model: 'user',
          key: 'id'
        },
        onUpdate: "restrict", // 更新时操作
        onDelete: "cascade", // 删除时操作
      },
      created_at: DATE,
      updated_at: DATE,
    });
  },

  async down (queryInterface, Sequelize) {
    await queryInterface.dropTable('video_follows');
  }
};
